# coding: utf-8
import os
from dotenv import dotenv_values

env = {
    **dotenv_values(".env"),
    **os.environ
}

basedir = os.path.abspath(os.path.dirname(__file__))


class Config(object):
    LOGGER_PATH = './log'
    LOGGER_NAME = 'data_quality_assessment'
    LOGGER_ROTATION = '00:00'
    LOGGER_RETENTION = '7 days'

    @staticmethod
    def init_app(app):
        pass


class ProductConfig(Config):
    CONFIG_NAME = 'prod'

    WATCH_FOLDER = '/data/DataOcean/Beta-v1'
    WEB_HOOK = 'https://open.feishu.cn/open-apis/bot/v2/hook/b04df5ee-aad0-4891-9a9b-fbfffd997cfc'
    
    BACKEND_URL = 'https://www.emocares.com/api'

    DATABASE_NAME = 'eh_data'
    DATABASE_USERNAME = 'eh'
    DATABASE_PASSWORD = env.get('DATABASE_PASSWORD')
    DATABASE_HOST = '192.168.10.20'
    DATABASE_PORT = '5432'
    DATABASE_SERVER = 'postgresql'

    DATABASE_CLINICAL_NAME = 'clinical_backend_prod?charset=utf8'
    DATABASE_CLINICAL_USERNAME = 'eh'
    DATABASE_CLINICAL_PASSWORD = env.get('DATABASE_CLINICAL_PASSWORD')
    DATABASE_CLINICAL_HOST = '101.132.110.173'
    DATABASE_CLINICAL_PORT = '3306'
    DATABASE_CLINICAL_SERVER = 'mysql+pymysql'

    PATH_UNZIP = './tmp'
    PATH_RESOURCE = '/data/DataOcean/emo_data'


class PreConfig(Config):
    CONFIG_NAME = 'pre'

    WATCH_FOLDER = '/data/DataOcean/test'
    WEB_HOOK = 'https://open.feishu.cn/open-apis/bot/v2/hook/4be730bd-6bdb-47c1-befe-c85abf5ba785'

    BACKEND_URL = 'http://ibd4j.emocares.com/api'

    DATABASE_NAME = 'eh_data_test'
    DATABASE_USERNAME = 'eh'
    DATABASE_PASSWORD = env.get('DATABASE_PASSWORD_PRE')
    DATABASE_HOST = '192.168.10.20'
    DATABASE_PORT = '5432'
    DATABASE_SERVER = 'postgresql'
    
    DATABASE_CLINICAL_NAME = 'clinical_backend_pre?charset=utf8'
    DATABASE_CLINICAL_USERNAME = 'eh'
    DATABASE_CLINICAL_PASSWORD = env.get('DATABASE_CLINICAL_PASSWORD_PRE')
    DATABASE_CLINICAL_HOST = '101.132.110.173'
    DATABASE_CLINICAL_PORT = '3307'
    DATABASE_CLINICAL_SERVER = 'mysql+pymysql'

    PATH_UNZIP = './tmp_test_unzip'
    PATH_RESOURCE = './tmp_test_resource'


class TestingConfig(Config):
    CONFIG_NAME = 'test'

    WATCH_FOLDER = '/data/DataOcean/test'
    WEB_HOOK = 'https://open.feishu.cn/open-apis/bot/v2/hook/4be730bd-6bdb-47c1-befe-c85abf5ba785'

    BACKEND_URL = 'http://api.eh.com'

    DATABASE_NAME = 'eh_data_test'
    DATABASE_USERNAME = 'eh'
    DATABASE_PASSWORD = env.get('DATABASE_PASSWORD_TEST')
    DATABASE_HOST = '192.168.10.20'
    DATABASE_PORT = '5432'
    DATABASE_SERVER = 'postgresql'
    
    DATABASE_CLINICAL_NAME = 'clinical_backend_test?charset=utf8'
    DATABASE_CLINICAL_USERNAME = 'eh'
    DATABASE_CLINICAL_PASSWORD = env.get('DATABASE_CLINICAL_PASSWORD_TEST')
    DATABASE_CLINICAL_HOST = '192.168.10.128'
    DATABASE_CLINICAL_PORT = '3306'
    DATABASE_CLINICAL_SERVER = 'mysql+pymysql'

    PATH_UNZIP = './tmp_test_unzip'
    PATH_RESOURCE = './tmp_test_resource'


config = {
    'prod': ProductConfig,
    'test': TestingConfig,
    'pre': PreConfig,
}[env.get('MODE')]
